package com.lanhai.zhonglai.beans;

import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.List;

import com.lanhai.zhonglai.dao.ControlAreaDao;
import com.lanhai.zhonglai.utils.Tools;


/**
 * 弃用，保留
 * @author zhengwei
 *
 */
public class ControlAreaBean {
	private long areaid; 
	private GeneralPath peneralPath;
	
	
	public ControlAreaBean(ControlAreaDao dao) {
	
		this.areaid=dao.getId();
		
		List<Double> xarr=Tools.strToDoubleList("");
		List<Double> yarr=Tools.strToDoubleList("");
		
		
		List<Point2D.Double> pointList=new ArrayList<Point2D.Double>();
		for(int i=0;i<xarr.size() && i<yarr.size();i++) {
			Point2D.Double pd=new Point2D.Double( xarr.get(i) , yarr.get(i) );
			pointList.add(pd);
		}
		
		if(pointList.size()<3) {
			return ;
		}
		
		 peneralPath = new  GeneralPath(); 
        Point2D.Double first = pointList.get(0);
        // 通过移动到指定坐标（以双精度指定），将一个点添加到路径中
        peneralPath.moveTo(first.x, first.y);
        pointList.remove(0);
        for (Point2D.Double d : pointList) { 
            peneralPath.lineTo(d.x, d.y);
        }
        // 将几何多边形封闭
        peneralPath.lineTo(first.x, first.y);
        peneralPath.closePath();
	}
	
	public boolean inArea(int x,int y) {
		if(peneralPath==null) return false;
		return peneralPath.contains(x, y);
	}
	
	
	
	public long getAreaid() {
		return areaid;
	}
  
	
}
